package demo2;

/*public class Test {
    public static void main(String[] args) {

        Cycle cycle=new Cycle();
        Flower flower=new Flower();
        Rect rect=new Rect();
        Trian trian=new Trian();
        //非多态方法
        *//*String[] shapes={"Cycle","Flower","Rect","Trian"};
        for(String shape:shapes){
            if(shape=="Cycle"){
                cycle.draw();
            } else if (shape=="Flower") {
                flower.draw();
            }else if(shape=="Rect"){
                rect.draw();
            }else{
                trian.draw();
            }
        }*//*

        //多态方法
        Shape[] shapes={cycle,flower,rect,trian};
        for(Shape shape:shapes){
            shape.draw();
        }
    }
}*/
class B {
    public B() {
        // do nothing
        func();
    }
    public void func() {
        System.out.println("B.func()");
    }
}
class D extends B {
    private int num = 1;
    @Override
    public void func() {
        System.out.println("D.func() " + num);
    }
}
public class Test {
    public static void main(String[] args) {
        D d = new D();
    }
}